const express = require('express');
const router = express.Router();
const { 
  getRandomHealthKnowledge,
  getAllHealthKnowledge,
  getHealthKnowledgeById,
  createHealthKnowledge,
  updateHealthKnowledge,
  deleteHealthKnowledge,
  likeHealthKnowledge
} = require('../controllers/healthKnowledgeController');
const { protect } = require('../middleware/authMiddleware');

// 公共路由
router.get('/random', getRandomHealthKnowledge);
router.get('/', getAllHealthKnowledge);
router.get('/:id', getHealthKnowledgeById);
router.put('/:id/like', likeHealthKnowledge);

// 管理员路由 - 临时移除admin中间件，仅使用protect
router.post('/', protect, createHealthKnowledge);
router.put('/:id', protect, updateHealthKnowledge);
router.delete('/:id', protect, deleteHealthKnowledge);

module.exports = router; 